home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / natbib / natbib.sty < prev    next >
Text File  |  1994-05-30  |  11KB  |  261 lines

  1. %% 
  2. %% This is file `natbib.sty', generated 
  3. %% on <1994/5/27> with the docstrip utility (2.2e).
  4. %% 
  5. %% The original source files were:
  6. %% 
  7. %% natbib.dtx  (with options: `package,209,all')
  8. %% 
  9. %% The original file natbib.dtx contains LaTeX text as comments, which 
  10. %% may be processed by LaTeXing the appropriate driver (.drv) file. 
  11. %% This produces a more detailed description of the macro usage and of its 
  12. %% coding than is to be found in the limited remaining comments in this file. 
  13. %% 
  14. %% >>>>> Start of decommented natbib.dtx >>>>>>> 
  15. %%======================NATBIB.DTX========================================
  16. \def\filename{natbib}
  17. \def\fileversion{5.0}
  18. \def\filedate{1994/05/18}
  19.  %-------------------------------------------------------------------
  20.  % NOTICE:
  21.  % This file may be used for non-profit purposes.
  22.  % It may not be distributed in exchange for money,
  23.  %   other than distribution costs.
  24.  %
  25.  % The author provides it `as is' and does not guarantee it in any way.
  26.  %
  27. %% Copyright (C) 1994 Patrick W. Daly
  28.  % Max-Planck-Institut f\"ur Aeronomie
  29.  % Postfach 20
  30.  % D-37189 Katlenburg-Lindau
  31.  % Germany
  32.  %
  33.  % E-mail:
  34.  % SPAN--     nsp::linmpi::daly    (note nsp also known as ecd1)
  35.  % Internet-- daly@linax1.dnet.gwdg.de
  36.  %-----------------------------------------------------------
  37.  % Intended mainly for author-year style citations, but will work with
  38.  % numericals as well.
  39.  %
  40.  % If author-year style selected, then \bibitem must have one of the
  41.  %   following forms:
  42.  %   \bibitem[Jones et al.(1990)]{key}...
  43.  %   \bibitem[Jones et al., 1990]{key}...
  44.  %   \bibitem[\protect\citeauthoryear{Jones, Baker, and Williams}{Jones
  45.  %       et al.}{1990}]{key}...
  46.  %   \bibitem[\protect\citeauthoryear{Jones et al.}{1990}]{key}...
  47.  %   \bibitem[\protect\astroncite{Jones et al.}{1990}]{key}...
  48.  %   \bibitem[\protect\citename{Jones et al., }1990]{key}...
  49.  %   \harvarditem[Jones et al.]{Jones, Baker, and Williams}{1990}{key}...
  50.  %
  51.  % This is either to be made up manually, or to be generated by an
  52.  % appropriate .bst file with BibTeX.
  53.  %
  54.  % Then, \cite{key}  ==>>  Jones et al. (1990)
  55.  %       \cite[]{key} ==>> (Jones et al., 1990)
  56.  % Multiple citations as normal:
  57.  %       \cite[]{key1,key2} ==>> (Jones et al., 1990; Smith, 1989)
  58.  %                           or  (Jones et al., 1990, 1991)
  59.  % Optional notes as:
  60.  %   \cite[chap. 2]{key}    ==>> (Jones et al., 1990, chap. 2)
  61.  %   \cite[e.g.,][]{key}    ==>> (e.g., Jones et al., 1990)
  62.  %   \cite[see][pg. 34]{key}==>> (see Jones et al., 1990, pg. 34)
  63.  %  (Note: in standard LaTeX, only one note is allowed, after the ref.
  64.  %   Here, one note is like the standard, two make pre- and post-notes.)
  65.  %
  66.  % Additional citation possibilities (author-year only)
  67.  %   \citeauthor{key}  ==>> Jones et al.
  68.  %   \citeyear{key}    ==>> 1990
  69.  % (Multiple keys NOT allowed!)
  70.  %
  71.  % Defining the citation style of a given bib style:
  72.  % Use \bibpunct with 6 arguments:
  73.  %    1. opening bracket for citation
  74.  %    2. closing bracket
  75.  %    3. citation separator (for multiple citations in one \cite)
  76.  %    4. the letter n for numerical styles, else anything for author-year
  77.  %    5. punctuation between authors and date
  78.  %    6. punctuation between years when common authors missing
  79.  % Example (and default) \bibpunct{(}{)}{;}{a}{,}{,}
  80.  %
  81.  % To make this automatic for a given bib style, named newbib, say, add
  82.  % to this style file
  83.  %   \bibstyle@newbib{\bibpunct... + any other redefinitions (see examples)}
  84.  % Then the \bibliographystyle{newbib} will cause \bibstyle@newbib to
  85.  % be called on THE NEXT LATEX RUN (via the aux file).
  86.  %
  87.  % LaTeX2e Options: (for selecting punctuation)
  88.  %   round  -  round parentheses are used (default)
  89.  %   square -  square braces are used
  90.  %   colon  -  multiple citations separated by colon (default)
  91.  %   comma  -  separated by comma
  92.  %   authoryear - selects author-year citations (default)
  93.  %   numbers-  selects numerical citations
  94.  %   nobibstyle - deactivates punctuation selection via \bibliographystyle
  95.  % Note: normally the punctuation style defined by \bibstyle@xxx and invoked
  96.  %       with \bibliographystyle{xxx} dominates; with option nobibstyle
  97.  %       this is no longer the case.
  98.  % LaTeX2e options are called as, e.g.
  99.  %        \usepackage[square,comma]{natbib}
  100.  %-----------------------------------------------------------
  101. \typeout{Package: `\filename' v\fileversion\space <\filedate> --P.W.Daly}
  102. \newif\if@twoOnine \let\if@twoOnine=\if@compatibility
  103. \@ifundefined{documentclass}{
  104.     \@twoOninetrue
  105. }{
  106.     \NeedsTeXFormat{LaTeX2e}
  107.     \ProvidesPackage{\filename}[\filedate\space (PWD)]
  108. }
  109.  % Define citation punctuation for some author-year styles
  110.  % One may add and delete at this point
  111. \def\bibstyle@aa{\bibpunct{(}{)}{;}{a}{}{,}}
  112. \def\bibstyle@pass{\bibpunct{(}{)}{;}{a}{,}{,}}
  113. \def\bibstyle@anngeo{\bibpunct{(}{)}{;}{a}{,}{,}}
  114. \def\bibstyle@agu{\bibpunct{[}{]}{;}{a}{,}{,}}
  115. \def\bibstyle@nlinproc{\bibpunct{(}{)}{;}{a}{,}{,}}
  116.  % Define citation punctuation for some numerical styles
  117.  % One may add and delete at this point
  118. \def\bibstyle@cospar{\bibpunct{/}{/}{,}{n}{}{}%
  119.      \gdef\@biblabel##1{##1.}}
  120. \def\bibstyle@esa{\bibpunct{(}{)}{,}{n}{}{}%
  121.      \gdef\@biblabel##1{##1.\hspace{1em}}%
  122.      \gdef\@cite##1##2##3{\@citebegin Ref.~##1\if@tempswa,
  123.           ##3\fi\@citeend}}
  124. \def\bibstyle@nature{\bibpunct{}{}{,}{n}{}{}%
  125.      \gdef\@biblabel##1{##1.}%
  126.      \gdef\@cite##1##2##3{\unskip\mbox{$^{##1}$}}}
  127.  % The standard LaTeX styles
  128. \def\bibstyle@plain{\bibpunct{[}{]}{,}{n}{}{}}
  129. \let\bibstyle@alpha=\bibstyle@plain
  130. \let\bibstyle@abbrv=\bibstyle@plain
  131. \let\bibstyle@unsrt=\bibstyle@plain
  132. \if@twoOnine\else
  133. \DeclareOption{round}{\def\@citebegin{(} \def\@citeend{)}}
  134. \DeclareOption{square}{\def\@citebegin{[} \def\@citeend{]}}
  135. \DeclareOption{comma}{\def\@citesep{,}}
  136. \DeclareOption{colon}{\def\@citesep{;}}
  137. \DeclareOption{numbers}{\let\@bibsetup=\@bibsetnum
  138.    \let\@citex=\@citexnum
  139.    \let\@biblabel=\@biblabelnum
  140.    \let\@cite=\@citenum
  141.    \ExecuteOptions{square,comma}}
  142. \DeclareOption{super}{\ExecuteOptions{numbers}%
  143.       \def\@cite##1##2##3{\unskip\mbox{$^{##1}$%
  144.           \if@tempswa(##3)\fi}}}
  145. \DeclareOption{authoryear}{}
  146. \DeclareOption{nobibstyle}{\let\bibstyle=\@gobble}
  147. \fi
  148. \def\@cite#1#2#3{\if@tempswa\@citebegin\if#2\@empty\else#2 \fi
  149.         #1\if#3\@empty\else, #3\fi\@citeend\else#1\fi}
  150. \def\@citenum#1#2#3{\@citebegin\if@tempswa\if#2\@empty\else#2 \fi\fi
  151.    #1\if#3\@empty\else, #3\fi\@citeend}
  152. \def\@citexnum[#1][#2]#3{\if@filesw\immediate\write
  153.       \@auxout{\string\citation{#3}}\fi
  154.   \let\@citea\@empty
  155.   \@cite{\@for\@citeb:=#3\do
  156.     {\@citea\def\@citea{\@citesep\penalty\@m\ }%
  157.      \def\@tempa##1##2\@nil{\edef\@citeb{\if##1\space##2\else##1##2\fi}}%
  158.      \expandafter\@tempa\@citeb\@nil
  159.      \@ifundefined{b@\@citeb}{{\reset@font\bfseries ?}\@warning
  160.        {Citation `\@citeb' on page \thepage \space undefined}}%
  161.      \hbox{\csname b@\@citeb\endcsname}}}{#1}{#2}}
  162. \def\@citex[#1][#2]#3{\if@filesw\immediate\write
  163.      \@auxout{\string\citation{#3}}\fi
  164.   \let\@citea\@empty
  165.   \@cite{\let\@citenm\@empty
  166.     \@for\@citeb:=#3\do
  167.     {\def\@tempa##1##2\@nil{\edef\@citeb{\if##1\space##2\else##1##2\fi}}%
  168.      \expandafter\@tempa\@citeb\@nil
  169.      \@ifundefined{b@\@citeb}{\@citea{\reset@font\bfseries ?}\@warning
  170.        {Citation `\@citeb' on page \thepage \space undefined}}%
  171.      {\let\@citemm=\@citenm
  172.      \@cite@parse{\@citeb}%
  173.      \if@tempswa
  174.        \ifx\@citemm\@citenm\@yrsep\else\@citea{\@citenm}\@auyrsep\fi
  175.        \ \@citedt \def\@citea{\@citesep\ }%
  176.      \else
  177.        \ifx\@citemm\@citenm, \@citedt\else\@citea{\@citenm}
  178.            \@citebegin\@citedt\fi
  179.        \def\@citea{\@citeend\@citesep\ }%
  180.      \fi}}\if@tempswa\else\@citeend\fi}{#1}{#2}}
  181. \def\@biblabel#1{\hfill}
  182. \def\@biblabelnum#1{[#1]}
  183. \def\@bibsetnum#1{\settowidth\labelwidth{\@biblabel{#1}}%
  184.    \leftmargin\labelwidth \advance\leftmargin\labelsep}
  185. \def\@bibsetup#1{\leftmargin=1em\itemindent=-\leftmargin}
  186. \if@twoOnine
  187. \def\@citebegin{(} \def\@citeend{)} \def\@citesep{;}
  188. \else
  189. \ExecuteOptions{authoryear,round,colon}
  190. \ProcessOptions
  191. \fi
  192. \def\@auyrsep{,} \def\@yrsep{,}
  193. \def\bibstyle#1{\@ifundefined{bibstyle@#1}{\relax}
  194.      {\csname bibstyle@#1\endcsname}}
  195. \if@twoOnine
  196. \let\ori@document=\document
  197. \def\document{\ori@document\global\let\bibstyle=\@gobble}
  198. \else
  199. \AtBeginDocument{\global\let\bibstyle=\@gobble}
  200. \fi
  201. \def\bibpunct#1#2#3#4#5#6{\gdef\@citebegin{#1}\gdef\@citeend{#2}\gdef
  202.    \@citesep{#3}\ifx #4n\global\let\@bibsetup=\@bibsetnum
  203.    \global\let\@citex=\@citexnum
  204.    \global\let\@biblabel=\@biblabelnum
  205.    \global\let\@cite=\@citenum\fi
  206.    \gdef\@auyrsep{#5}\gdef\@yrsep{#6}}
  207. \def\cite{\@ifnextchar [{\@tempswatrue\@citex@}{\@tempswafalse
  208.     \@citex@[]}}
  209. \def\@citex@[#1]{\@ifnextchar [{\@citex[#1]}{\@citex[][#1]}}
  210. \def\citeauthor#1{\ifx\@citex\@citexnum{\reset@font\bfseries(author?)}\@warning
  211.        {Cannot use \string\citeauthor\space with numerical citations}\else
  212.      \@ifundefined{b@#1}{{\reset@font\bfseries ?}\@warning
  213.        {Citation `#1' on page \thepage \space undefined}}%
  214.        {\@cite@parse{#1}\@citenm}\fi}
  215. \def\citeyear#1{\ifx\@citex\@citexnum{\reset@font\bfseries(year?)}\@warning
  216.        {Cannot use \string\citeyear\space with numerical citations}\else
  217.      \@ifundefined{b@#1}{{\reset@font\bfseries ?}\@warning
  218.        {Citation `#1' on page \thepage \space undefined}}%
  219.        {\@cite@parse{#1}\@citedt}\fi}
  220. \def\@cite@parse#1{%
  221.         {\let\prm=\relax\let\psf=\relax\let\ptt=\relax\let\pbf=\relax
  222.         \let\psl=\relax\let\psc=\relax\let\pit=\relax\let\pem=\relax
  223.         \let\prmfamily=\relax\let\psffamily=\relax\let\pttfamily=\relax
  224.         \let\pbfseries=\relax\let\pslshape=\relax\let\pscshape=\relax
  225.         \let\pitshape=\relax\let\pmdseries=\relax\let\pupshape=\relax
  226.         \let\pc=\relax \let\pd=\relax \let\pb=\relax
  227.      \xdef\@tempa{\csname b@#1\endcsname\relax}}%
  228.      \expandafter\@citez\@tempa()\@nil}
  229. \def\@citez#1(#2)#3\@nil{\gdef\@citenm{#1}\gdef\@citedt{#2}%
  230.   \if!#2!\expandafter\@citeapalk#1\@nil\fi}
  231. \def\@citeapalk#1, #2\@nil{\gdef\@citenm{#1}\gdef\@citedt{#2}}
  232. \def\citeauthoryear#1#2#3{\ifx#3\relax #1(#2)\else #2(#3)\fi}
  233.   \def\citestarts{\@citebegin}
  234.   \def\citeends{\@citeend}
  235.   \def\betweenauthors{and}
  236. \def\astroncite#1#2{#1(#2)}
  237. \def\citename#1{#1}
  238. \def\harvarditem{\@ifnextchar[{\@harvarditem}{\@harvarditem[\@empty]}}
  239. \def\@harvarditem[#1]#2#3#4{\if!#1!\bibitem[#2(#3)]{#4}\else
  240.   \bibitem[#1(#3)]{#4}\fi }
  241. \@ifundefined{chapter}{\def\bibsection{\section*{\refname
  242.    \@mkboth{\uppercase{\refname}}{\uppercase{\refname}}}}}{\def
  243.    \bibsection{\chapter*{\bibname
  244.    \@mkboth{\uppercase{\bibname}}{\uppercase{\bibname}}}}}
  245. \def\thebibliography#1{\bibsection\parindent \z@\list
  246.  {\@biblabel{\arabic{enumiv}}}{\@bibsetup{#1}%
  247.     \usecounter{enumiv}\let\p@enumiv\@empty
  248.     \def\theenumiv{\arabic{enumiv}}}%
  249.     \def\newblock{\hskip .11em plus.33em minus.07em}%
  250.     \sloppy\clubpenalty4000\widowpenalty4000
  251.     \sfcode`\.=1000\relax \bibfont}
  252. \let\bibfont=\relax
  253. \def\endthebibliography{%
  254.   \def\@noitemerr{\@warning{Empty `thebibliography' environment}}%
  255.   \endlist\vskip-\lastskip}
  256. \@ifundefined{reset@font}{\let\reset@font=\relax}{}
  257. \@ifundefined{bfseries}{\let\bfseries=\bf}{}
  258. %% <<<<< End of decommented file <<<<<< 
  259. %% 
  260. %% End of file natbib.sty. 
  261.